'http://www.blitzmax.com/Community/posts.php?topic=90686
Strict
Graphics 640,480
Local timestart# = MilliSecs() / 1000.0

Local t# = 0.5
Local tweendir# = 1
While Not KeyHit(KEY_ESCAPE)
	Local timeSeconds# = MilliSecs() / 1000.0
	Local dt# = timeSeconds-timestart
	timestart = timeSeconds

	Cls
	
	If t >= 1.0 tweenDir = -1
	If t <= 0.0 tweenDir = 1	
	t = t+0.5*dt*tweenDir 'MouseY() / 480.0

	DrawText "t = "+t, 320,15
	
	Local x# = 0
	x= TweenSineUp(0,600,t)
	DrawOval(x,50*1,40,40)
	DrawText("sine up", x+50,20+50*1)
	
	x= TweenUp(0,600,t)
	DrawOval(x,50*2,40,40)
	DrawText("smooth up", x+50,20+50*2)

	x= TweenSineDown(0,600,t)
	DrawOval(x,50*3,40,40)
	DrawText("sine down", x+50,20+50*3)
	
	x= TweenDown(0,600,t)
	DrawOval(x,50*4,40,40)
	DrawText("smooth down", x+50,20+50*4)	

	x= Tween(0,600,t)
	DrawOval(x,50*5,40,40)
	DrawText("linear", x+50,20+50*5)
	
	x= TweenSine(0,600,t)
	DrawOval(x,50*6,40,40)
	DrawText("sine", x+50,20+50*6)
	
	x = TweenSmooth(0,600,t)
	DrawOval(x,50*7,40,40)
	DrawText("smooth", x+50,20+50*7)
	Flip
Wend

Function Tween:Float(p1:Float, p2:Float, t:Float)
	Return p1 + t * (p2 - p1)
End Function

Function TweenSineUp:Float(p1:Float, p2:Float, t:Float)
	t=1-Sin((1-t) *90)
	Return p1 + t * (p2 - p1)
End Function

Function TweenSineDown:Float(p1:Float, p2:Float, t:Float)
	t=Sin(t*90)
	Return p1 + t * (p2 - p1)
End Function

Function TweenSine:Float(p1:Float, p2:Float, t:Float)
	t=(Sin(-90.0+180*t)+1)/2.0
	Return p1 + t * (p2 - p1)
End Function

Function TweenSmooth:Float(p1:Float, p2:Float, t:Float)
	Local v# = SmoothStep(t)
	Return p1 + v * (p2 - p1)
End Function

Function TweenUp:Float(p1:Float, p2:Float, t:Float)
	Local v# = SmoothStep(t)
	v=v^2 'Squared
	Return p1 + v * (p2 - p1)
End Function

Function TweenDown:Float(p1:Float, p2:Float, t:Float)
	Local v# = SmoothStep(t)
	v = 1-(1-v)^2 'InvSquared
	Return p1 + v * (p2 - p1)
End Function

Function SmoothStep:Float(x#)
	Return x*x * (3-2*x)
End Function
